//
//  L2MutableDictionary.m
//  Lesson2
//
//  Created by Alexander Trifonov on 20.04.12.
//  Copyright (c) 2012 fgengine@gmail.com. All rights reserved.
//

#import "L2MutableDictionary.h"

@implementation L2MutableDictionary

- (void) execute
{
    NSMutableDictionary *d1 = [NSMutableDictionary dictionaryWithCapacity:2];
    NSMutableDictionary *d2 = [[NSMutableDictionary alloc] initWithCapacity:2];
    [d2 release];
    
    NSLog(@"-L2MutableDictionary--------------------");
    
    [d1 setObject:@"String constant" forKey:@"string"];
    NSLog(@"%@", d1);
    
    NSLog(@"----------------------------------------");
    
    [d1 setObject:@"New value" forKey:@"string"];
    NSLog(@"%@", d1);
    
    NSLog(@"----------------------------------------");
    
    NSDictionary *d = [NSDictionary dictionaryWithObjectsAndKeys:
                       @"Shane Stanley", @"name",
                       @"Russia", @"country",
                       nil];
    [d1 addEntriesFromDictionary:d];
    NSLog(@"%@", d1);
    
    NSLog(@"----------------------------------------");
    
    NSDictionary *d3 = [NSDictionary dictionaryWithObjectsAndKeys:
                        @"Sara Konor", @"name",
                        @"USA", @"country",
                        @"111-555-1212", @"phone",
                        @"sk@gmail.com", @"email",
                        @"Programmer", @"profession",
                        nil];
    [d1 setDictionary:d3];
    NSLog(@"%@", d1);
    
    NSLog(@"----------------------------------------");
    
    [d1 removeObjectForKey:@"country"];
    NSLog(@"%@", d1);
    
    NSLog(@"----------------------------------------");
    
    NSArray *keysForRemove = [NSArray arrayWithObjects:@"phone", @"email", @"profession", nil];
    [d1 removeObjectsForKeys:keysForRemove];
    NSLog(@"%@", d1);
    
    NSLog(@"----------------------------------------");
    
    [d1 removeAllObjects];
    NSLog(@"%@", d1);
    
    NSLog(@"----------------------------------------");
}

@end
